package com.hydl.power.service.impl;

import com.hydl.power.mapper.HomePpageDataMapper;
import com.hydl.power.pojo.HomePpageData;
import com.hydl.power.service.HomePpageDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class HomePpageDataServiceImpl implements HomePpageDataService {
    /**
     查询首页数据信息
     * */
    @Autowired
    private HomePpageDataMapper homePpageDataMapper;
    @Override
    public HomePpageData queryHomePpageDataAll() {
        return homePpageDataMapper.queryHomePpageDataAll();
    }


    /**
    根据经纬度查询本项目下所有数据
    * */
    @Override
    public HomePpageData queryHomePpageDataById(String longitudeLatitude,String latitudeLatitude) {
        return homePpageDataMapper.queryHomePpageDataById(longitudeLatitude,latitudeLatitude);
    }

    @Override
    public String querydayElectricity(String longitudeLatitude, String latitudeLatitude) {
        Object dayElectricity= ((HomePpageData)homePpageDataMapper.querydayElectricity(longitudeLatitude,latitudeLatitude));
        if(dayElectricity==null){
            String week="0";
            return week;
        }
        return ((HomePpageData) dayElectricity).getDayElectricity();
    }


    @Override
    public String queryWeekElectricity(String longitudeLatitude, String latitudeLatitude) {
        Object weekElectricity= ((HomePpageData)homePpageDataMapper.queryWeekElectricity(longitudeLatitude,latitudeLatitude));
        if(weekElectricity==null){
            String week="0";
            return week;
        }
        return ((HomePpageData) weekElectricity).getWeekElectricity();
    }

    @Override
    public String queryMonthElectricity(String longitudeLatitude, String latitudeLatitude) {
        Object monthElectricity= ((HomePpageData)homePpageDataMapper.queryMonthElectricity(longitudeLatitude,latitudeLatitude));
        if(monthElectricity==null){
            String week="0";
            return week;
        }
        return ((HomePpageData) monthElectricity).getMonthElectricity();
    }

    @Override
    public String querySumElectricity(String longitudeLatitude, String latitudeLatitude) {
        Object sumElectricity= ((HomePpageData)homePpageDataMapper.querySumElectricity(longitudeLatitude,latitudeLatitude));
        if(sumElectricity==null){
            String week="0";
            return week;
        }
        return ((HomePpageData) sumElectricity).getSumElectricity();
    }

    @Override
    public String querySumPt(String longitudeLatitude, String latitudeLatitude) {
        Object sumElectricity= ((HomePpageData)homePpageDataMapper.querySumPt(longitudeLatitude,latitudeLatitude));
        if(sumElectricity==null){
            String Pt="0";
            return Pt;
        }
        return ((HomePpageData) sumElectricity).getPt();
    }
}
